In [1]:
import sympy
import numpy as np
sympy.init_printing()
Lets try to complete the examples in section 4-3 using Sympy instead of Matlab
Consider the transfer function:
$$ \frac{Y(s)}{U(s)} = \frac{s^4 + 8 s^3 + 16 s^2 + 9s + 6}{s^3 + 6s^2+11s +6} $$We want to use partial fraction expansion to simplify this expression
First we need to define the function in Python
In [5]:
s = sympy.symbols('s')
G = (s**4 + 8*s**3+16*s**2+9*s+6) / (s**3 + 6*s**2 + 11*s +6)
G
Out[5]:
Now we can expand using partial fractions
In [6]:
sympy.apart(G)
Out[6]:
In [10]:
F = 1 / s * (2*s+10)/(s**2+2*s+10)
F
Out[10]:
In [13]:
sympy.apart(F, full=True).doit()
Out[13]: